<!-- 主体部分 -->
<div class="layui-fluid" id="body">
    <!-- 内容主体区域 -->
    <blockquote class="layui-elem-quote layui-text">
        欢迎使用<strong>博客管理系统</strong>
    </blockquote>
    <div style="padding: 15px;">
        <!-- 面板 -->
        <div class="layui-card layui-panel">
            <div class="layui-card-header">
                文章添加
            </div>
            <div class="layui-card-body">
                <form class="layui-form" action="/index.php/index/addAtToSave" method="post" enctype="multipart/form-data" id="form1">
                    <div class="layui-form-item">
                        <label class="layui-form-label">文章标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" lay-verify="required" placeholder="请输入"
                                   autocomplete="off" class="layui-input" id="title">
<!--                            &lt;!&ndash;  默认传递的id 为0           &ndash;&gt;-->
<!--                            <input type="text" name="id" lay-verify="required" placeholder="请输入"-->
<!--                                   autocomplete="off" class="layui-input layui-hide" id="id" value="{}">-->
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">文章摘要</label>
                        <div class="layui-input-block">
                            <input type="text" name="summary" lay-verify="required" placeholder="请输入"
                                   autocomplete="off" class="layui-input" id="summary">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">添加封面</label>
                        <div class="layui-input-inline layui-input-wrap">
                            <input type="file"  class="layui-input" name="image">
                            <input type="text"  class="layui-input layui-hide" id="imgname">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">分类专栏</label>
                            <div class="layui-input-block">
                                <input type="checkbox" name="arr[0]" title="SpringBoot" value="springboot">
                                <input type="checkbox" name="arr[1]" title="ssm" value="ssm" checked>
                                <input type="checkbox" name="arr[2]" title="Linux" value="Linux">
                                <input type="checkbox" name="arr[3]" title="MySql" value="MySql">
                                <input type="checkbox" name="arr[4]" title="ThinkPHP" value="ThinkPHP">
                                <input type="checkbox" name="arr[5]" title="Redis" value="Redis">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">文章类型</label>
                            <div class="layui-input-block">
                                <select name="atType">
                                    <option value="不限类型">不限类型</option>
                                    <option value="原创">原创</option>
                                    <option value="转载">转载</option>
                                    <option value="翻译">翻译</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">文章标签</label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="label[0]" title="java" value="java">
                            <input type="checkbox" name="label[1]" title="python" value="python" checked>
                            <input type="checkbox" name="label[2]" title="php" value="php">
                            <input type="checkbox" name="label[3]" title="C" value="C">
                            <input type="checkbox" name="label[4]" title="Go" value="Go">
                            <input type="checkbox" name="label[5]" title="Hadoop" value="Hadoop">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">可见范围</label>
                        <div class="layui-input-block">
                            <input type="radio" name="range" value="全部可见" title="全部可见" checked>
                            <input type="radio" name="range" value="仅自己可见" title="仅自己可见">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label" >文章内容</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容" class="layui-textarea" style="height: 1000px;" name="content" id="content">

                            </textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="submit" class="layui-btn" id="atSubmit" >提交发布</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <br><br>
    </div>
</div>

<script>



    $("#atSubmit").click(function (){

        var id = $("#id").val();  //文章id
        var title = $("#title").val(); //标题
        var summary = $("#summary").val(); // 摘要
        var range = $("input[name='range']:checked").val(); //可见范围
        var atType = $("#atType").val(); //文章类型
        var content = $("#content").html(); //内容
        var image =$("input[type='file']").val(); // 图像路径




        if (title==""){
            layer.msg("文章标题不能为空")
        }else if(summary==""){
            layer.msg("文章摘要不能为空")
        }else if(image==""){
            layer.msg("请选择上传文件")
        }
        // else if(arr.toString()==""){
        //     layer.msg("请选择分类专栏")
        // }
        else if(atType==""){
            layer.msg("请选则文章类型")
        }
        // else if(label.toString()==""){
        //     layer.msg("请选择文章标签")
        // }
        else if(range==""){
            layer.msg("可见范围不能为空")
        }
        else if(content==""){
            layer.msg("请填写内容")
        }else{
           $("#atSubmit").onsubmit();
        }
    })
</script>